package edu.calpoly.android.echoes;

import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.RectF;
import android.util.Log;

public class MyRectangle implements MyDrawableShapes {
    float left;
    float top;
    float right;
    float bottom;
    float inX;
    float inY;
	Paint p;
	int color;
	
	private int screen;
	
	private static final int RECTANGLE_PADDING = 2;
    
		
	public MyRectangle(float left, float top, float right, float bottom, Paint pnt) {
		this.left = left;
		this.top = top;
		this.right = right;
		this.bottom = bottom;
		inX = (right+left)/2;
		inY = (bottom+top)/2;
		this.p = new Paint(pnt);
	}
	
	public MyRectangle(float left, float top, float right, float bottom, Paint pnt, int color) {
		this.left = left;
		this.top = top;
		this.right = right;
		this.bottom = bottom;
		inX = (right+left)/2;
		inY = (bottom+top)/2;
		this.p = new Paint(pnt);
		this.color = color;
	}
	
	public MyRectangle(float left, float top, float right, float bottom, Paint pnt, int color, int screen) {
		this.left = left;
		this.top = top;
		this.right = right;
		this.bottom = bottom;
		inX = (right+left)/2;
		inY = (bottom+top)/2;
		this.p = new Paint(pnt);
		this.color = color;
		this.screen = screen;
	}
	
	public void drawMe(Canvas c) {
		p.setColor(Color.BLACK);
		
		c.drawRect(new RectF(left, top, right, bottom), p);
		
		p.setColor(color);
		
		c.drawRect(new RectF(left+RECTANGLE_PADDING,
				top+RECTANGLE_PADDING, right-RECTANGLE_PADDING, bottom-RECTANGLE_PADDING), p);
	}
	
	public void drawMe(Canvas c, ColorSelectMenu csm) {
		p.setColor(Color.BLACK);
		
		c.drawRect(new RectF(left, top, right, bottom), p);
		
		p.setColor(csm.getCurrentColor());
		
		c.drawRect(new RectF(left+RECTANGLE_PADDING,
				top+RECTANGLE_PADDING, right-RECTANGLE_PADDING, bottom-RECTANGLE_PADDING), p);
	}
	
	public int getColorIndex() {
		if(color == Color.DKGRAY) return 0;
		if(color == Color.MAGENTA) return 1;
		if(color == Color.BLUE) return 2;
		if(color == Color.GREEN) return 3;
		if(color == Color.RED) return 4;
		if(color == Color.WHITE) return 5;
		if(color == Color.rgb(169,229,255)) return 6;
		if(color == Color.rgb(255,130,0)) return 7;
		return 0;
	}
	
	public Paint getPaint() {
		return p;
	}
	
	public void setPaint(Paint _p) {
		p = _p;
	}
	
	public float getX() {
		return inX;
	}
	
	public void setX(float _x) {
		inX = _x;
	}

	public float getY() {
		return inY;
	}
	
	public void setY(float _y) {
		inY = _y;
	}
	
	public float getLeft() {
		return left;
	}
	
	public float getTop() {
		return top;
	}
	
	public float getRight() {
		return right;
	}
	
	public float getBottom() {
		return bottom;
	}

	public void updateLoc() {
		// TODO Auto-generated method stub
		
	}

	public void setScreenNumber(int s) {
		screen = s;
	}
	
	public int getScreenNumber() {
		return screen;
	}
}
